package com.example.su_shi_tan_mine.child

import android.graphics.Color
import android.os.Bundle
import android.view.View
import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentStatePagerAdapter
import androidx.viewpager.widget.ViewPager
import com.alibaba.android.arouter.facade.annotation.Route
import com.example.su_shi_tan_bas_lib.base.BaseFragmentEx
import com.example.su_shi_tan_mine.R
import com.example.su_shi_tan_mine.arouter.SubPageARouter
import com.google.android.material.tabs.TabLayout

@Route(path = SubPageARouter.ReSettingPassWord)
class ReSettingPassWordFragment:BaseFragmentEx() {


    private val mToolbar by lazy {
        view?.findViewById<Toolbar>(R.id.mToolbar)
    }

    private val mTabLayout by lazy {
        view?.findViewById<TabLayout>(R.id.mTabLayout)
    }

    private val mViewPager by lazy {
        view?.findViewById<ViewPager>(R.id.mViewPager)
    }

    private val pageLs = listOf<BaseFragmentEx>(
        ReSettingSignInPasswordFragment.newInstance(),
        ReSettingPayingPasswordFragment.newInstance()
    )

    override fun getLayoutId(): Any {
        return R.layout.resetting_password_fragment
    }


    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        mToolbar?.title = "修改密码"
        mToolbar?.setNavigationOnClickListener { onBackPressedSupport() }


        mViewPager?.adapter = object : FragmentStatePagerAdapter
            (childFragmentManager, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
            override fun getCount(): Int {
                return pageLs.size
            }

            override fun getItem(position: Int): Fragment {
                return pageLs[position]
            }

            override fun getPageTitle(position: Int): CharSequence? {
                val lab = getItem(position) as ReSettingPassWordLab
                return lab.labInfo
            }

        }
        mTabLayout?.setupWithViewPager(mViewPager)
    }


}